<div class="map">
  <el-breadcrumb class="top" separator-class="el-icon-arrow-right">
    <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item>用户管理</el-breadcrumb-item>
    <el-breadcrumb-item>用户列表</el-breadcrumb-item>
  </el-breadcrumb>
  <div>
    <el-row :gutter="20">
      <el-col :span="8">
        <el-input placeholder="请输入查询内容" v-model="input5">
          <el-button
            @click="startQuery"
            slot="append"
            icon="el-icon-search"
          ></el-button>
        </el-input>
      </el-col>
      <el-col :span="3">
        <el-button @click="showAddUserDialog">添加用户</el-button>
      </el-col>
    </el-row>
  </div>
  <el-table :data="userList" style="width: 100%">
    <el-table-column prop="username" label="姓名" width="180"></el-table-column>
    <el-table-column prop="email" label="邮箱" width="180"></el-table-column>
    <el-table-column prop="mobile" label="电话"></el-table-column>
    <el-table-column label="用戶状态">
      <template slot-scope='scope'>
        <el-switch
          v-model="scope.row.mg_state"
          active-color="#009FFF"
          inactive-color="#DBDFE6"
          @change='stateChange(scope.row)'
        >
        </el-switch>
      </template>
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          type="primary"
          icon="el-icon-edit"
          size="mini"
          plain
          @click="editUserShow(scope.row)"
        ></el-button>
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          plain
          @click="delUser(scope.row.id)"
        ></el-button>
        <el-button type="success" icon="el-icon-check" size="mini" plain
          >分配角色</el-button
        >
      </template>
    </el-table-column>
  </el-table>
  <el-pagination
    class="pagination"
    background
    :page-size="2"
    layout="prev, pager, next"
    @current-change="pageChange"
    :current-page="pagenum"
    :total="total"
  ></el-pagination>

  <!-- 添加用户 -->
  <!-- <el-dialog title="添加用户" :visible.sync="dialogAddUserVisible">
    <el-form
      :model="addUserForm"
      :rules="rules"
      label-width="100px"
    >
      <el-form-item label="用户名" prop="username">
        <el-input v-model="addUserForm.username" ></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input v-model="addUserForm.password"></el-input>
      </el-form-item>
      <el-form-item label="邮箱" prop="email">
        <el-input v-model="addUserForm.email"></el-input>
      </el-form-item>
      <el-form-item label="手机" prop="mobile">
        <el-input v-model="addUserForm.mobile"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer">
      <el-button @click="dialogAddUserVisible = false">取 消</el-button>
      <el-button type="primary" @click="">确 定</el-button>
    </div>
  </el-dialog> -->

  <!-- 添加用户 -->

  <el-dialog title="添加用户" :visible.sync="dialogAddUserVisible" class="main">
    <el-form :model="addUserForm" label-width="100px" :rules="rules">
      <el-form-item label="用户名" prop="username">
        <el-input v-model="addUserForm.username" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input v-model="addUserForm.password" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input v-model="addUserForm.email" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="手机">
        <el-input v-model="addUserForm.mobile" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer">
      <el-button @click="dialogAddUserVisible = false">取 消</el-button>
      <el-button type="primary" @click="addUser">确 定</el-button>
    </div>
  </el-dialog>

  <!-- 编辑用户对话框 -->

  <el-dialog title="编辑用户" :visible.sync="dialogEditUserVisible">
    <el-form :model="editUserForm" label-width="100px">
      <el-form-item label="用户名">
        <el-tag type="info">{{editUserForm.username}}</el-tag>
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input v-model="editUserForm.email" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="手机">
        <el-input v-model="editUserForm.mobile" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer">
      <el-button @click="dialogEditUserVisible = false">取 消</el-button>
      <el-button type="primary" @click="editUser">确 定</el-button>
    </div>
  </el-dialog>
</div>
